﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using App.Core.Extensions;
using App.Data;
using System.Data;

public partial class Pages_Admin_ManageSubscription : BasePage
{
    
    
    protected void Page_Load(object sender, EventArgs e)
    {
        BindPageInfo();
        if (!IsPostBack)
        {            
            BindUserList(1);
        }
    }

    protected void BindPageInfo()
    {
        Page.Title = WebUtil.GetPageTitle(h4Heading.InnerHtml);       
        
    }

    protected void BindUserList(int pageNumber)
    {
        
        int totalRecord = 0;
        UtilityDAO dao = new UtilityDAO();
        //App.Data.DbParameter[] parameters = new[] { new App.Data.DbParameter("@CustomerID", customerID) };
        DataSet ds = dao.GetPagedData(AppSQL.GET_PAGED_CUSTOMERS_BY_SUBSCRIPTION, null, pageNumber, ConfigReader.CommonListPageSize, out totalRecord);
        ucUserList.DataSource = ds.Tables[0];
        ucUserList.EditLink = AppConstants.Pages.SUBSCRIPTION_CHANGE + "?" + AppConstants.QueryString.ID + "={0}&" + AppConstants.QueryString.CUSTOMER_ID + "={1}";

        ucUserList.LinkFields = "SubscriptionID, CustomerID";
        ucUserList.DataBind();

        divListingContainer.Visible = true;
        

        ///Bind Pager
        ucUserListPager.TotalRecord = totalRecord;
        ucUserListPager.PageNo = pageNumber;
        ucUserListPager.PageSize = ConfigReader.CommonListPageSize;
        ucUserListPager.TotalRecordMessage = "Total {0} Customer(s) Found.";
        ucUserListPager.DataBind();

    }

    protected void ucUserListPager_PageIndexChanged(object sender, PagerEventArgs e)
    {
        BindUserList(e.PageIndex);
    }
}